package com.luhan.lhframe.fragment;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.loopj.android.http.AsyncHttpResponseHandler;
import com.luhan.lhframe.R;
import com.luhan.lhframe.api.remote.MyHttpApi;
import com.luhan.lhframe.base.BaseFragment;

import butterknife.Bind;
import butterknife.ButterKnife;
import cz.msebera.android.httpclient.Header;

/**
 * 登录用户中心页面
 */
public class MyInformationFragment extends BaseFragment {
    @Bind(R.id.btn_login)
    Button btn_login;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_my_information, container, false);
        ButterKnife.bind(this, view);
        initView(view);
        return view;
    }

    @Override
    public void initView(View view) {
        super.initView(view);
        btn_login.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.btn_login:
                showWaitDialog("正在登陆哦。。。");
                MyHttpApi.login("1", "2", new AsyncHttpResponseHandler() {
                    @Override
                    public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                        Log.d("testaaa", "onSuccess: " + statusCode );
                    }

                    @Override
                    public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                        Log.d("testaaa", "onFailure: " + statusCode + new String(responseBody));
                    }

                    @Override
                    public void onFinish() {
                        Log.d("testaaa", "onFinish: ");
                        hideWaitDialog();
                        super.onFinish();
                    }
                });

                break;
        }
    }
}
